//
//  SFJumpWebViewController.m
//  GiftThat
//
//  Created by dllo on 16/1/9.
//  Copyright © 2016年 ChuXiang. All rights reserved.
//

#import "SFJumpWebViewController.h"
#import "UMSocial.h"
@interface SFJumpWebViewController ()<UIWebViewDelegate>
@property (nonatomic,strong) NSString *NewUrl;
@property (nonatomic,strong) UIImageView *imageView;
@end

@implementation SFJumpWebViewController

-(void)viewWillAppear:(BOOL)animated{
    self.imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0,0 , 80, 80)];
    self.imageView.backgroundColor = [UIColor blackColor];
    self.imageView.alpha = 0.5;
    self.imageView.center = CGPointMake(self.view.width / 2, self.view.height / 2 - 80);
    NSMutableArray*muArray = [NSMutableArray array];
    for (int i = 0; i < 15; i++) {
        [muArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"loading_%d",i]]];
    }
    [self.imageView setAnimationImages:muArray];
    [self.imageView setAnimationDuration:3];
    [self.imageView startAnimating];
    [self.view addSubview:self.imageView];
    
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        
        [self.imageView stopAnimating];
        [self.imageView removeFromSuperview];
    });

}

- (instancetype)initWithURL:(NSString *)Url
{
    self = [super init];
    if (self) {
        self.NewUrl = Url;

    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"攻略详情";
    
     self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]style:UIBarButtonItemStyleDone target:self action:@selector(leftButton:)];
    NSURL *url = [NSURL URLWithString:self.NewUrl];
    NSURLRequest *request =[NSURLRequest requestWithURL:url];
    UIWebView *webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 53)];
    webView.delegate = self;
    [webView loadRequest:request];
    [self.view addSubview:webView];
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithImage:[[UIImage imageNamed:@"share"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(shareURLString)];
    
    self.navigationItem.rightBarButtonItem = item;
  
}





- (void)leftButton:(UIButton *)button {
  
    [self.navigationController popViewControllerAnimated:YES];

}

-(void)shareURLString{
    
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"507fcab25270157b37000010"
                                      shareText:self.NewUrl                                     shareImage:[UIImage imageNamed:@"icon.png"]
                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToWechatSession,UMShareToQQ,UMShareToTencent,nil]
                                       delegate:self];
    
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
